﻿#include <sb.h>

kint tmfn(kpointer ptr, kint interval)
{
	kDateTime dt;

	k_now(&dt);

	k_mesgf("\n#### %d: %02d:%02d:%02d.%03d\n", interval, dt.hour, dt.minute, dt.second, dt.millisecond);

	return interval;
}

//
int main(void)
{
	k_output_log_time(TRUE);
	k_mesg("TIME EVENT TEST\n");
	k_srand(0);

	int id = k_ttes_queue(1000, tmfn, NULL);

	for (;;)
	{
		k_printf("--->");
		int ch = getchar();

		if (ch == 'q')
			break;
		else if (ch == '1')
		{
			if (id == 0)
				id = k_ttes_queue(k_rand_int(1, 10) * 100, tmfn, NULL);
			else
			{
				k_ttes_remove(id);
				id = 0;
			}
		}
	}

	return 0;
}

